package com.gz.logistics.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 预出库单下的 商品实体
 * author wanner1991
 */
public class WillOutStorageProdoctInfo {

    private String product_name;//商品名称
    private String quantity;//商品份数
    private String unit;//商品单位

    public String getProduct_name() {
        return product_name;
    }

    public void setProduct_name(String product_name) {
        this.product_name = product_name;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getShop_name() {
        return shop_name;
    }

    private String shop_name;//伊利乳业

    public void setShop_name(String shop_name) {
        this.shop_name = shop_name;
    }

    public static List<WillOutStorageProdoctInfo> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray == null || jsonArray.length() <= 0 ){
            return null;
        }
        List<WillOutStorageProdoctInfo> infos = new ArrayList<WillOutStorageProdoctInfo>();

        for (int i = 0 ; i < jsonArray.length() ; i ++ ){

            WillOutStorageProdoctInfo info = new WillOutStorageProdoctInfo();
            JSONObject object = jsonArray.getJSONObject(i);

            info.product_name = object.getString("product_name");
            info.quantity = object.getString("quantity");
            info.unit = object.getString("unit");
            info.shop_name = object.getString("shop_name");
            infos.add(info);

        }
        return infos;
    }
}
